#ifndef LOGINCODE_H
#define LOGINCODE_H
#include "settingwidget.h"

#include <QLabel>
#include <QMap>
#include <QMouseEvent>
#include <QPainter>
#include <QStyleOption>
#include <QToolButton>
#include <QVBoxLayout>
#include <QtWidgets/QDialog>

class loginCode : public QDialog
{
    Q_OBJECT
public:
    loginCode(QWidget *parent = nullptr);

private slots:
    void onBtnSetClicked();
    void onCloseWidget();
    void onBtnPhoneClicked();

private:
    bool eventFilter(QObject *watch, QEvent *event) override;

    void setToolBtn(QToolButton *btn,
                    const QString &objectName,
                    const QSize &size,
                    const QString &text,
                    Qt::ToolButtonStyle style,
                    const QString &styleSheet,
                    bool useIcon,
                    const QString &iconURL,
                    const uint8_t width = 0,
                    const uint8_t heigth = 0);
    void changeIcon(QAbstractButton *btn, const QString &iconURL);
    void addButtonIconMapping(QAbstractButton *button,
                              const QString &iconEnter,
                              const QString &iconLevel);

protected:
    // void mousePressEvent(QMouseEvent *event) override;
    // void mouseMoveEvent(QMouseEvent *event) override;
    // void mouseReleaseEvent(QMouseEvent *event) override;
    // void paintEvent(QPaintEvent *event) override;
private:
    QVBoxLayout *mainVLayout;
    QHBoxLayout *setBarHLayoout;
    QPushButton *btnSet;
    QLabel *label_logo;
    QHBoxLayout *logoHLayout;
    QPushButton *btnweChatLogin;
    QPushButton *btnJoin;
    QToolButton *toolBtnPhone;
    QToolButton *toolBtnEmail;
    QToolButton *toolBtnPasswd;
    QScopedPointer<settingWidget> settingPtr;
    // bool m_dragging;
    // QPoint m_offset;
    QMap<QAbstractButton *, QPair<QString, QString>> buttonIconMap;
};

#endif // LOGINCODE_H
